#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <errno.h>

#include "interface.h"

#define ARRAY_SIZE(a)	(sizeof(a) / sizeof(a[0]))

void set_buzzer(int cmd)
{
	int i;
	int fd;
	int ret;
	unsigned int freq;

	fd = open("/dev/pwm", O_RDWR);
	if (fd == -1)
		goto fail;
	ret = ioctl(fd, BUZZ_S);
	if (ret == -1)
		goto fail;
	if(cmd >0)
	{
		ret = ioctl(fd, BUZZ_L, cmd);
		if (ret == -1)
		goto fail;
		
	}
	else
		ret = ioctl(fd, BUZZ_D);
		if (ret == -1)
			goto fail;
		close(fd);
	return;
fail:
	perror("pwm test");
	exit(EXIT_FAILURE);
}

